import { createRouter, createWebHistory } from 'vue-router'

// 动态路由
import aboutRouter from './modules/about'
import newsRouter from './modules/news'
import caseRouter from './modules/case'
import contactRouter from './modules/contact'

export const BASIC_ROUTES = [
  aboutRouter,
  newsRouter,
  caseRouter,
  contactRouter,
  {
    path: '/',
    component: () => import('@/views/home/index.vue')
  },
  {
    path: '/login',
    component: () => import('@/views/login/index.vue')
  },
  {
    path: '/403',
    component: () => import(/* webpackChunkName: 'exception' */ '@/views/exception/403.vue')
  },
  {
    path: '/404',
    component: () => import(/* webpackChunkName: 'exception' */ '@/views/exception/404.vue')
  },
  {
    path: '/500',
    component: () => import(/* webpackChunkName: 'exception' */ '@/views/exception/500.vue')
  }
]

export const ASYNC_ROUTES = [
  {
    noAuth: true,
    path: '/:catchAll(.*)',
    redirect: '/404'
  }
]

const router = createRouter({
  history: createWebHistory(),
  scrollBehavior: () => ({ top: 0 }),
  routes: BASIC_ROUTES
})

export default router
